cmake_minimum_required(VERSION 3.10)
project(course_03)

set(CMAKE_CXX_STANDARD 11)  # 将 C++ 标准设置为 C++ 11
set(CMAKE_CXX_STANDARD_REQUIRED ON)  # C++ 11 是强制要求，不会衰退至低版本
set(CMAKE_CXX_EXTENSIONS OFF)  # 禁止使用编译器特有扩展

if(NOT CMAKE_BUILD_TYPE)
    message(WARNING "NOT SET CMAKE_BUILD_TYPE")
    set(CMAKE_BUILD_TYPE "Release")
endif()

#使用aux_source_directory获取所有源文件,src 目录
aux_source_directory(src SRC)
message("SRC内容是->${SRC}" )#SRC内容 src/add.cpp;src/main.cpp;src/sub.cpp

set(INCLUDE "include")

#add_executable 生成可执行文件run
add_executable(run ${SRC})
#add_library 生成共享库或者静态库目标
add_library(math SHARED ${SRC})  #生成共享库math
add_library(maths STATIC ${SRC})  #生成静态库static

#为目标添加文件包含路径
target_sources(run PRIVATE ${SRC})
target_include_directories(run PRIVATE ${INCLUDE})